EventDispatcher
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Known subclasses: | |
| Classpath: | gfx.events.EventDispatcher |
| File last modified: | Tuesday, 29 June 2010, 09:03:27 |
The EventDispatcher manages the notification mechanism used throughout the components. EventDispatcher can be inherited from, or mixed in to add notification capabilities to a class. The Scaleform EventDispatcher mirrors the API in the Macromedia AS2 EventDispatcher, and the common methods found in the AS3 EventDispatcher, but also includes some enhancements, such as the removeAllEventListeners method.
Summary
Constructor
Class methods
- initialize
- Initialize a component or class, adding Event Dispatching capabilities to it.
Instance methods
- addEventListener
- Subscribe a listener to an event.
- removeEventListener
- Unsubscribe a listener from an event.
- dispatchEvent
- Dispatch an event to all listeners.
- hasEventListener
- Check if a listener has been added for a specific event type.
- removeAllEventListeners
- Unsubscribe all listeners from a specific event, or all events.
- cleanUp
- Clean up the EventDispatcher instance.
Constructor
EventDispatcher
function EventDispatcher (
)
Create a new EventDispatcher, which is an Object capable of broadcasting events. It is more likely that the EventDispatcher will be extended, or the static
EventDispatcher.initialize() method will be used to add event-broadcasting capabilities to a component. Class methods
initialize
static function initialize (
target:Object) : Void
Initialize a component or class, adding Event Dispatching capabilities to it.
Instance methods
addEventListener
function addEventListener (
event:String,
scope:Object,
callBack:String) : Void
Subscribe a listener to an event.
Parameters:
event :
The type of event.
scope :
The scope of the listener.
callBack:
The function name to call on the listener.
cleanUp
function cleanUp (
) : Void
Clean up the EventDispatcher instance. The cleanUp method is not used to clean up EventDispatcher sub-classes, and is not mixed-in to components when the static initialize() method is used. Use cleanUpEvents.() instead.
dispatchEvent
function dispatchEvent (
event:Object) : Void
Dispatch an event to all listeners.
Parameters:
event:
The event object to dispatch to the listeners.
hasEventListener
function hasEventListener (
event:String) : Boolean
Check if a listener has been added for a specific event type.
Parameters:
event :
The event type
scope :
The scope of the listener.
callBack:
The function name to call on the listener.
Returns:
- If the component has a specific listener
removeAllEventListeners
function removeAllEventListeners (
event:String) : Void
Unsubscribe all listeners from a specific event, or all events.
Parameters:
event:
The type of event.
removeEventListener
function removeEventListener (
event:String,
scope:Object,
callBack:String) : Void
Unsubscribe a listener from an event.
Parameters:
event :
The type of event.
scope :
The scope of the listener.
callBack:
The function name to call on the listener.